<?php
/**
 * @Notes:【】
 * @Date: 2022-11-26 0:48
 */

namespace App\Controller\Admin\User;

use App\Controller\Admin\BaseController;
use App\Service\User\UserSpreadSettingService;
use Hyperf\Di\Annotation\Inject;
use Yj\Apidog\Annotation\ApiController;
use Yj\Apidog\Annotation\FormData;
use Yj\Apidog\Annotation\PostApi;

/**
 * @ApiController(prefix="admin/user/UserSpreadSetting")
 */
class UserSpreadSettingController extends BaseController
{
    /**
     * @Inject()
     * @var UserSpreadSettingService
     */
    protected $userSpreadSettingService;

    /**
     * @PostApi(path="lists")
     */
    public function lists()
    {
        $params = $this->getParams();
        $data = $this->userSpreadSettingService->lists($params);
        _SUCCESS($data);
    }

    /**
     * @Notes:【】
     * @Date: 2022-11-26 0:54
     * @PostApi(path="add")
     * @FormData(key="people")
     * @FormData(key="num")
     */
    public function add()
    {
        $params = $this->getParams();
        $data = $this->userSpreadSettingService->add($params);
        _SUCCESS($data);
    }

    /**
     * @Notes:【】
     * @Date: 2022-11-26 0:54
     * @PostApi(path="edit")
     * @FormData(key="people")
     * @FormData(key="num")
     * @FormData(key="id")
     */
    public function edit()
    {
        $params = $this->getParams();
        $data = $this->userSpreadSettingService->edit($params->get('id'), $params->except('id'));
        _SUCCESS();
    }

    /**
     * @Notes:【】
     * @Date: 2022-11-26 0:54
     * @PostApi(path="delete")
     * @FormData(key="id")
     */
    public function del()
    {
        $id = $this->getParams()->get('id');
        $this->userSpreadSettingService->del($id);
        _SUCCESS();
    }

}